import React from "react";
import classNames from "classnames";
import { useMount, useReactive } from "ahooks";
import styles from "./index.module.less";
import utilsFilter from "../../utils/filters";
import Overlay from "../../compoents/overlay";
import utilsBase from "../../utils/basc";
import { useDispatch, useSelector } from "react-redux";
import useServices from "../../hooks/useRequest";
import { exportNft, analysisFee } from "../../api/nft";
import { setPayPassword2 } from "../../api/user";
import useRouteInfo from "../../hooks/useRouter";
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
var Nftend = function() {
    var back = function back() {
        dispatch.app.PUSH(prevPath);
    };
    var clicksend = function clicksend() {
        if (!utilsBase._checkethaddress(state.address)) {
            state.showerror = true;
            return;
        } else {
            state.showerror = false;
        }
        if (state.address) {
            if (userInfo.payPassword) {
                state.intpasswordshow = true;
                state.blurshow = true;
            } else {
                state.passwordshow = true;
                state.blurshow = true;
            }
        }
    };
    var setpass = function setpass() {
        if (state.pass1 && state.pass2 == state.pass1) {
            state.blurshow = false;
            state.passwordshow = false;
            services.setPayPassword2({
                pwd: state.pass1
            }, true).then(function(res) {
                state.pass1 = "";
                state.pass2 = "";
                if (res.code == 200) {
                    dispatch.app.setUserInfo();
                    state.blurshow = true;
                    state.intpasswordshow = true;
                }
            }).catch(function(err) {
                console.log("err", err);
                state.pass1 = "";
                state.pass2 = "";
            });
        }
    };
    var intpass = function intpass() {
        if (state.pass) {
            state.intpasswordshow = false;
            state.blurshow = false;
            var params = [
                {
                    nftId: state.detail.id,
                    toAddress: state.address
                }
            ];
            services.exportNft(params, true).then(function(res) {
                dispatch.app.setUserInfo();
                state.pass = "";
                if (res.code == 200) {
                    state.successshow = true;
                    state.blurshow = true;
                    setTimeout(function() {
                        state.successshow = false;
                        state.blurshow = false;
                        state.address = "";
                        back();
                    }, 2000);
                } else {}
            }).catch(function(err) {
                console.log("err", err);
                state.pass = "";
            });
        }
    };
    var getfee = function getfee() {
        services.analysisFee({
            nftType: state.detail.chainType
        }, false).then(function(res) {
            if (res.code == 200) {
                state.fee = res.data.fee;
            } else {}
        }).catch(function(err) {});
    };
    var _useRouteInfo = useRouteInfo(), query = _useRouteInfo.location.query;
    var state = useReactive({
        show: false,
        address: "",
        pass1: "",
        pass2: "",
        pass: "",
        detail: {},
        fee: "0",
        showerror: false,
        blurshow: false,
        intpasswordshow: false,
        passwordshow: false,
        successshow: false
    });
    var _useSelector = useSelector(function(state) {
        return {
            userInfo: state.app.userInfo,
            prevPath: state.app.prevPath
        };
    }), userInfo = _useSelector.userInfo, prevPath = _useSelector.prevPath;
    var dispatch = useDispatch();
    var services = useServices({
        setPayPassword2: setPayPassword2,
        exportNft: exportNft,
        analysisFee: analysisFee
    });
    useMount(function() {
        state.detail = (query === null || query === void 0 ? void 0 : query.detail) || {};
        getfee();
    });
    return /*#__PURE__*/ _jsxs("div", {
        className: styles.content,
        children: [
            /*#__PURE__*/ _jsxs("div", {
                className: classNames(styles.bodybox),
                style: {
                    zIndex: 10,
                    position: "relative",
                    width: "100%",
                    height: "100%"
                },
                children: [
                    /*#__PURE__*/ _jsx("img", {
                        className: styles.backimg,
                        onClick: back,
                        src: require("../../assets/public/back2.png"),
                        alt: ""
                    }),
                    /*#__PURE__*/ _jsx("div", {
                        className: classNames("font-16", styles.name, "text-center Montserrat-ExtraBold"),
                        children: state.detail.name
                    }),
                    /*#__PURE__*/ _jsx("div", {
                        className: styles.img,
                        style: {
                            filter: state.show ? "blur(2px)" : "none"
                        },
                        children: /*#__PURE__*/ _jsx("img", {
                            className: styles.imgt,
                            src: state.detail.nftLogo
                        })
                    }),
                    /*#__PURE__*/ _jsx("div", {
                        className: "font-zi Montserrat-Bold text-center mt-25",
                        children: "SEND TO"
                    }),
                    /*#__PURE__*/ _jsx("div", {
                        className: classNames(styles.amountboxintk, "flex-center flex-j-around"),
                        children: /*#__PURE__*/ _jsx("div", {
                            className: classNames(styles.amountboxintbg, "flex-center"),
                            children: /*#__PURE__*/ _jsx("input", {
                                className: classNames(styles.intzi, " Montserrat-Medium"),
                                "placeholder-class": styles.inttszi,
                                type: "text",
                                value: state.address,
                                onChange: function(e) {
                                    state.address = e.target.value;
                                },
                                "v-model": "address",
                                placeholder: "ENTER ADDRESS"
                            })
                        })
                    }),
                    state.showerror && /*#__PURE__*/ _jsx("div", {
                        className: classNames("text-center font-red font-10 Montserrat-Medium mt-5", styles.errorclass),
                        "v-if": "showerror",
                        children: "Incorrect address"
                    }),
                    /*#__PURE__*/ _jsxs("div", {
                        className: "flex-center flex-j-between pdl mt-20",
                        children: [
                            /*#__PURE__*/ _jsx("div", {
                                className: "font-13 Montserrat-Bold font-zi",
                                children: "Network Fee"
                            }),
                            /*#__PURE__*/ _jsxs("div", {
                                className: "font-11 font-zi Montserrat-SemiBold",
                                children: [
                                    state.fee,
                                    " ",
                                    state.detail.chainType == "ERC721" ? "ETH" : "BNB"
                                ]
                            })
                        ]
                    }),
                    /*#__PURE__*/ _jsxs("div", {
                        className: "flex-center flex-j-between pdl mt-5",
                        children: [
                            /*#__PURE__*/ _jsx("div", {
                                className: "font-13 Montserrat-Bold font-zi",
                                children: "Token Standard"
                            }),
                            /*#__PURE__*/ _jsx("div", {
                                className: "font-11 Montserrat-Medium",
                                children: state.detail.agreement
                            })
                        ]
                    }),
                    /*#__PURE__*/ _jsxs("div", {
                        className: "flex-center flex-j-between pdl mt-5",
                        children: [
                            /*#__PURE__*/ _jsx("div", {
                                className: "font-13 Montserrat-Bold font-zi",
                                children: "Token ID"
                            }),
                            /*#__PURE__*/ _jsx("div", {
                                className: "font-11 Montserrat-Medium",
                                children: state.detail.tokenId
                            })
                        ]
                    }),
                    /*#__PURE__*/ _jsxs("div", {
                        className: "flex-center flex-j-between pdl mt-5",
                        children: [
                            /*#__PURE__*/ _jsx("div", {
                                className: "font-13 Montserrat-Bold font-zi",
                                children: "Token Contract"
                            }),
                            /*#__PURE__*/ _jsx("div", {
                                className: "font-11 Montserrat-Medium",
                                children: utilsFilter.stringMethod(state.detail.contract)
                            })
                        ]
                    }),
                    /*#__PURE__*/ _jsxs("div", {
                        className: styles.sendbtnbox2,
                        onClick: clicksend,
                        children: [
                            /*#__PURE__*/ _jsx("img", {
                                className: classNames(styles.icon48, styles.btniconl),
                                src: state.address ? require("../../assets/public/sendicon.png") : require("../../assets/public/sendh.png")
                            }),
                            /*#__PURE__*/ _jsx("div", {
                                className: classNames("font-11", state.address ? styles.actbtncolor : ""),
                                children: "SEND"
                            })
                        ]
                    })
                ]
            }),
            /*#__PURE__*/ _jsxs(Overlay, {
                className: styles.verlayclass,
                style: {
                    backgroundColor: "rbga(255,255,255,.7)"
                },
                show: state.blurshow,
                onClick: function() {
                    state.blurshow = false;
                },
                children: [
                    state.intpasswordshow && /*#__PURE__*/ _jsxs("div", {
                        className: styles.passwordk,
                        "v-show": "intpasswordshow",
                        onClick: function(e) {
                            e.stopPropagation();
                        },
                        children: [
                            /*#__PURE__*/ _jsx("img", {
                                className: styles.passwordbg,
                                src: require("../../assets/public/popupbg.png")
                            }),
                            /*#__PURE__*/ _jsxs("div", {
                                className: styles.passwordinfo,
                                style: {
                                    paddingTop: "75px"
                                },
                                children: [
                                    /*#__PURE__*/ _jsx("div", {
                                        className: "font-12 Montserrat-SemiBold font-zi text-center",
                                        style: {
                                            width: 175,
                                            margin: "0 auto"
                                        },
                                        children: "PLEASE KEY IN TRADING PASSWORD"
                                    }),
                                    /*#__PURE__*/ _jsx("div", {
                                        className: classNames(styles.passwordintk2, "flex-center flex-j-around mt-20"),
                                        children: /*#__PURE__*/ _jsx("div", {
                                            className: classNames(styles.passwordintbg2, "flex-center"),
                                            children: /*#__PURE__*/ _jsx("input", {
                                                maxLength: 6,
                                                className: classNames(styles.passwordzi2, "Montserrat-Medium"),
                                                "placeholder-class": styles.passwordtszi2,
                                                type: "password",
                                                value: state.pass,
                                                onChange: function(e) {
                                                    state.pass = e.target.value;
                                                },
                                                "v-model": "pass",
                                                placeholder: "ENTER PASSWORD"
                                            })
                                        })
                                    }),
                                    /*#__PURE__*/ _jsxs("div", {
                                        className: classNames(styles.passwordbtnbox, "flex-center mt-50"),
                                        children: [
                                            /*#__PURE__*/ _jsxs("div", {
                                                className: classNames(styles.btn1, "flex-center flex-j-around", state.pass ? "" : styles.btnh),
                                                style: {
                                                    marginLeft: 23
                                                },
                                                onClick: function() {
                                                    return intpass();
                                                },
                                                children: [
                                                    /*#__PURE__*/ _jsx("div", {
                                                        className: "font-13 Montserrat-Bold font-white",
                                                        children: "CONFIRM"
                                                    }),
                                                    /*#__PURE__*/ _jsx("img", {
                                                        className: classNames(styles.icon48, styles.btniconl),
                                                        src: state.pass ? require("../../assets/public/sendicon.png") : require("../../assets/public/sendh.png")
                                                    })
                                                ]
                                            }),
                                            /*#__PURE__*/ _jsxs("div", {
                                                className: classNames(styles.btn2, "flex-center flex-j-around ", styles.sendbtnboxbt2),
                                                onClick: function() {
                                                    state.intpasswordshow = false;
                                                    state.blurshow = false;
                                                },
                                                children: [
                                                    /*#__PURE__*/ _jsx("div", {
                                                        className: "font-13 Montserrat-Bold font-zi",
                                                        children: "BACK"
                                                    }),
                                                    /*#__PURE__*/ _jsx("img", {
                                                        className: classNames(styles.icon48, styles.btniconrb),
                                                        src: require("../../assets/public/back.png")
                                                    })
                                                ]
                                            })
                                        ]
                                    })
                                ]
                            })
                        ]
                    }),
                    state.passwordshow && /*#__PURE__*/ _jsxs("div", {
                        className: styles.passwordk,
                        "v-show": "passwordshow",
                        onClick: function(e) {
                            e.stopPropagation();
                        },
                        children: [
                            /*#__PURE__*/ _jsx("img", {
                                className: styles.passwordbg,
                                src: require("../../assets/public/popupbg.png")
                            }),
                            /*#__PURE__*/ _jsxs("div", {
                                className: styles.passwordinfo,
                                children: [
                                    /*#__PURE__*/ _jsx("div", {
                                        className: "font-12 Montserrat-SemiBold font-zi text-center",
                                        children: "PLEASE SET YOUR 6-DIGIT TRADING PASSWORD"
                                    }),
                                    /*#__PURE__*/ _jsx("div", {
                                        className: classNames(styles.passwordintk2, "flex-center flex-j-around mt-20"),
                                        children: /*#__PURE__*/ _jsx("div", {
                                            className: classNames(styles.passwordintbg2, "flex-center"),
                                            children: /*#__PURE__*/ _jsx("input", {
                                                maxLength: 6,
                                                className: classNames(styles.passwordzi2, "Montserrat-Medium"),
                                                "placeholder-class": styles.passwordtszi2,
                                                type: "password",
                                                value: state.pass1,
                                                onChange: function(e) {
                                                    state.pass1 = e.target.value;
                                                },
                                                "v-model": "pass1",
                                                placeholder: "ENTER PASSWORD"
                                            })
                                        })
                                    }),
                                    /*#__PURE__*/ _jsx("div", {
                                        className: classNames(styles.passwordintk2, "flex-center flex-j-around mt-10"),
                                        children: /*#__PURE__*/ _jsx("div", {
                                            className: classNames(styles.passwordintbg2, "flex-center"),
                                            children: /*#__PURE__*/ _jsx("input", {
                                                maxLength: 6,
                                                className: classNames(styles.passwordzi2, "Montserrat-Medium"),
                                                "placeholder-class": styles.passwordtszi2,
                                                type: "password",
                                                "v-model": "pass2",
                                                value: state.pass2,
                                                onChange: function(e) {
                                                    state.pass2 = e.target.value;
                                                },
                                                placeholder: "RE-RNTER PASSWORD"
                                            })
                                        })
                                    }),
                                    /*#__PURE__*/ _jsxs("div", {
                                        className: classNames(styles.passwordbtnbox, "flex-center"),
                                        children: [
                                            /*#__PURE__*/ _jsxs("div", {
                                                className: classNames(styles.btn1, "flex-center flex-j-around", state.pass1 && state.pass2 == state.pass1 ? "" : styles.btnh),
                                                style: {
                                                    marginLeft: 23
                                                },
                                                onClick: setpass,
                                                children: [
                                                    /*#__PURE__*/ _jsx("div", {
                                                        className: "font-13 Montserrat-Bold font-white",
                                                        children: "NEXT"
                                                    }),
                                                    /*#__PURE__*/ _jsx("img", {
                                                        className: classNames(styles.icon48, styles.btniconl),
                                                        src: state.pass1 && state.pass2 == state.pass1 ? require("../../assets/public/back.png") : require("../../assets/public/backh.png"),
                                                        style: {
                                                            transform: state.pass1 && state.pass2 == state.pass1 ? "rotate(180deg);" : ""
                                                        }
                                                    })
                                                ]
                                            }),
                                            /*#__PURE__*/ _jsxs("div", {
                                                className: classNames(styles.btn2, "flex-center flex-j-around", styles.sendbtnboxbt2),
                                                onClick: function() {
                                                    state.passwordshow = false;
                                                    state.blurshow = false;
                                                },
                                                children: [
                                                    /*#__PURE__*/ _jsx("div", {
                                                        className: "font-13 Montserrat-Bold font-zi",
                                                        children: "BACK"
                                                    }),
                                                    /*#__PURE__*/ _jsx("img", {
                                                        className: classNames(styles.icon48, styles.btniconrb),
                                                        src: require("../../assets/public/back.png")
                                                    })
                                                ]
                                            })
                                        ]
                                    })
                                ]
                            })
                        ]
                    }),
                    state.successshow && /*#__PURE__*/ _jsxs("div", {
                        className: styles.passwordk,
                        "v-show": "successshow",
                        onClick: function(e) {
                            e.stopPropagation();
                        },
                        children: [
                            /*#__PURE__*/ _jsx("img", {
                                className: classNames(styles.passwordbg),
                                src: require("../../assets/public/popupbg.png")
                            }),
                            /*#__PURE__*/ _jsxs("div", {
                                className: classNames(styles.passwordinfo, "text-center"),
                                style: {
                                    paddingTop: 75
                                },
                                children: [
                                    /*#__PURE__*/ _jsx("img", {
                                        style: {
                                            width: 48,
                                            height: 48,
                                            margin: "auto"
                                        },
                                        src: require("../../assets/public/success.png")
                                    }),
                                    /*#__PURE__*/ _jsx("div", {
                                        className: "font-18 Montserrat-Bold font-zi text-center mt-20",
                                        children: "SEND SUCCEED"
                                    })
                                ]
                            })
                        ]
                    })
                ]
            })
        ]
    });
};
export default Nftend;

 //# sourceMappingURL=index.js.map